<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="UTF-8" />
    <title>登录</title>
    <#--/公共引入包-->
    <#include "include.ftl">
    <#---->
    <link rel="stylesheet" href="/view/ubox/ubox.css">
    <style>
        .tip{
            color:red;
            display:none;
        }
    </style>
</head>
<body class="background_grey">
    <#--/header-->
    <#include "header.ftl">
    <#---->
    <div class="register">
        <div class="register_enter_in">
            <div class="register_enter_title">
                <h2>登录粤科众包</h2>
                <p>聚众人 · 汇众智</p>
            </div>
            <div class="register_enter_ipt phone">
                <input type="text" placeholder="手机号码" id="register_phone" maxlength="11" />
            </div>
            <div class="register_enter_ipt password">
                <input type="password"  placeholder="密码" maxlength="16" id="register_password"/>
            </div>
            <div class="register_enter_forget">
                <span>没有账号<a href="/user/toregister">注册一个</a></span>
                <em><a href="#">忘记密码</a></em>
            </div>
            <div class="register_enter_forget">
                <span class="tip">用户名或密码不正确，登录失败</span>
            </div>
            <div class="register_enter_btn register_btn" id="register_btn">
                立即登录
            </div>
            <div class="register_enter_contact">
                <span class="line"></span>
                <span class="font">社交账号登录</span>
                <span class="wx"></span>
                <span class="qq"></span>
            </div>
        </div>
    </div>
    <div class="index_footer">
        <div class="index_footer_link">
            <a href="">新闻公告</a>|
            <a href="">关于我们</a>|
            <a href="">联系我们</a>|
            <a href="">用户协议</a>
        </div>
        <p class="index_footer_copy">Copyright©2016 yk-zb.com 粤科众包 版权所有 粤ICP备16027165号-1</p>
    </div>
</body>
<script type="text/javascript" src="/js/validate_input_data_1.0.js"></script>
<script type="text/javascript" src="/view/ubox/ubox.js"></script>
<script type="text/javascript" src="/js/md5.js"></script>
</html>
<script type="text/javascript">
    $(function() {

        if(window.localStorage){
            var storage=window.localStorage;
            //写入用户手机号字段
            var mobile = storage[USER_MOBILE];
            //写入用户密码字段
            if(mobile && mobile!="null"){
                $('#register_phone').val(mobile);
            }
        }

        /*提交*/
        $('#register_btn').click(function(event) {
            var registerPhone = $('#register_phone').val();
            var registerPassword = $('#register_password').val();

            if(!registerPhone){
                $('.tip').text("手机号不能为空！");
                $('.tip').show();
                return false;
            }
            if(!checkPhone(registerPhone)){
                $('.tip').text("手机号码不正确！");
                $('.tip').show();
                return false;
            }
            if(!registerPassword){
                $('.tip').text("密码不能为空！");
                $('.tip').show();
                return false;
            }
            $('#register_btn').text("登录中...");
            $.ajax({
                  type: "POST",
                  url: '/user/login',   //提交地址
                  data : {
                      userName:registerPhone,
                      password:$.md5(registerPassword)
                  },
                  dataType: "json",
                  success: function(data){
                      $('#register_btn').text("立即登录");
                      if(data && data.success){
                            if(data.data){
                                if(window.localStorage){
                                    var storage=window.localStorage;
                                    //写入用户手机号字段
                                    storage[USER_MOBILE]=registerPhone;
                                    //写入用户密码字段
                                    storage[USER_PASS]=$.md5(registerPassword);
                                }
                                $(".tip").hide();
                                layer.msg('登录成功！正在返回上一页面...');
                                setTimeout(function() {
                                    window.location.href=document.referrer;
                                }, 2000)
                            }else{
                                $(".tip").show();
                            }
                       }else{
                           $(".tip").show();
                       }
                  },
                  error: function(data){
                      $('#register_btn').text("立即登录");
                      $('.tip').text("登录失败！");
                      $('.tip').show();
                  }
            });
        });
        
        (function fnHeight(){
            var iHeight = $(window).height();
            var navHeight = $('.header').height();
            var footHeight = $('.index_footer').height();
            var registerHeight = $('.register').height()+170;
            console.log(iHeight,navHeight ,footHeight ,registerHeight)
            if(navHeight + footHeight + registerHeight < iHeight){
                $('.index_footer').css({"position":"absolute","bottom":"0"})
            }else{
                $('.index_footer').css({"position":"static"})
            }
            
        })();
    });
</script>